package org.phalanx.client.menus;

import java.awt.Color;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import org.phalanx.client.mapeditor.PhalanxMapEditorPanel;

public class DesignMenuPopUp extends JPopupMenu {
	private JMenuItem setDefaultTile;
	private JMenuItem changeTileSet;
	private JMenuItem changeMapProperties;
	private JMenuItem changeMapSize;
	
	private PhalanxMapEditorPanel masterPanel;
	private DesignMenuAction action; 
	
	public DesignMenuPopUp(PhalanxMapEditorPanel parentPanel){
		this.masterPanel = parentPanel;
		initializeMenu();
		setUpMenuItems();
		addMenuComponents();
	}
	
	private void initializeMenu(){
		this.setBackground(Color.white);
		this.setForeground(Color.black);
	}
	
	private void setUpMenuItems(){
		action = new DesignMenuAction(masterPanel);
		setDefaultTile = getMenuItemTemplate();
		setDefaultTile.setText("Set Default Tile...");
		setDefaultTile.setName("setdefaulttile");
		
		changeTileSet = getMenuItemTemplate();
		changeTileSet.setText("Change Tileset...");
		changeTileSet.setName("changetileset");
		
		changeMapProperties = getMenuItemTemplate();
		changeMapProperties.setText("Change Map Properties");
		changeMapProperties.setName("mapproperties");
		
		changeMapSize = getMenuItemTemplate();
		changeMapSize.setText("Resize Map");
		changeMapSize.setName("resizemap");
		
		
		setDefaultTile.addActionListener(action);
		changeTileSet.addActionListener(action);
		changeMapProperties.addActionListener(action);
		changeMapSize.addActionListener(action);
		
	}
	
	private void addMenuComponents(){
		this.add(setDefaultTile);
		this.add(changeTileSet);
		this.add(changeMapSize);
		this.add(changeMapProperties);
	}
	
	private JMenuItem getMenuItemTemplate(){
		JMenuItem defaultMenuItem = new JMenuItem();
		defaultMenuItem.setBackground(Color.white);
		defaultMenuItem.setForeground(Color.black);
		
		return defaultMenuItem;
	}
}
